﻿using Publicuse.Entity;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Publicuse.Interface
{
    public interface IBaseEFCoreService : IDisposable
    {
        /// <summary>
        /// 新增
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        void Insert<T>(T entity,out string msg) where  T:class, new();

        /// <summary>
        /// 新增
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        void Insert<T>(IEnumerable<T> entity,out string msg) where T:class,new();

        /// <summary>
        /// 删除
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="msg"></param>
        void Delete<T>(T entity,out string msg) where T:class,new();

        /// <summary>
        /// 删除
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <param name="msg"></param>
        void Delete<T>(int id, out string msg) where T : class, new();

        /// <summary>
        /// 删除
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="msg"></param>
        void Delete<T>(IEnumerable<T> entity,out string msg) where T:class,new();

        /// <summary>
        /// 修改
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        void Update<T>(T entity, out string msg) where T : class, new();

        /// <summary>
        /// 修改
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="id"></param>
        /// <param name="msg"></param>
        void Update<T>(T t, int id, out string msg) where T : class;

        /// <summary>
        /// 修改
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        void Update<T>(IEnumerable<T> entity,out string msg) where T : class, new();

        /// <summary>
        /// 查询
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        T FindByID<T>(string id, out string msg) where T : class, new();

        /// <summary>
        /// 查询
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="S"></typeparam>
        /// <param name="funcWhere"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="funcOrder"></param>
        /// <param name="msg"></param>
        /// <param name="isAsc"></param>
        /// <returns></returns>
        PageResult<T> QueryPage<T, S>(Expression<Func<T, bool>> funcWhere, int pageIndex,
      int pageSize, Expression<Func<T, S>> funcOrder, out string msg, bool isAsc) where T : class, new();

        /// <summary>
        /// 查询
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="expression"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        IQueryable<T> Query<T>(Expression<Func<T, bool>> expression, out string msg) where T : class, new();

        /// <summary>
        /// 执行SQL
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sql"></param>
        /// <param name="msg"></param>
        /// <param name="parameters"></param>
        void ExecuteSql<T>(string sql,out string msg, params object[] parameters ) where T : class;

        /// <summary>
        /// 查询
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="sql"></param>
        /// <param name="msg"></param>
        /// <param name="list"></param>
        /// <param name="parameters"></param>
        void ExecuteQuery<T>(T entity, string sql, out string msg, out List<T> list, params object[] parameters ) where T : class, new();

    }


}
